package com.cskaoyan.controller;

/**
 * @author lxy
 * @create 2021-10-22 20:19
 */

import com.cskaoyan.bean.Comment;
import com.cskaoyan.bean.CountCommentVo;
import com.cskaoyan.bean.basebean.BasePageData;
import com.cskaoyan.bean.basebean.BaseParam;
import com.cskaoyan.bean.basebean.BaseRespVo;
import com.cskaoyan.exception.CommentException;
import com.cskaoyan.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * wx评论管理
 */
@RestController
@RequestMapping("wx/comment")
public class WXCommentController {

    @Autowired
    CommentService commentService;

    // 查询所有评论信息
    @RequestMapping("list")
    public BaseRespVo list(Integer valueId, Byte type, BaseParam baseParam) {
        BasePageData data = commentService.queryWXAllComment(valueId,type,baseParam);
        return BaseRespVo.ok(data);
    }

    // 查询评论个数
    @RequestMapping("count")
    public BaseRespVo count(Integer valueId, Byte type) {
        CountCommentVo countCommentVo = commentService.countComment(valueId,type);
        return BaseRespVo.ok(countCommentVo);
    }

    // 添加评论
    @RequestMapping("post")
    public BaseRespVo post(@RequestBody Comment comment) throws CommentException {
        Comment commentVo = commentService.addComment(comment);
        return BaseRespVo.ok(commentVo);
    }
}
